//add by yuanfei
#include <map.h>
#include "cocos2d.h"
#include "HttpClient.h"

using namespace cocos2d::extension;
using namespace std;

class HttpHandler : public CCObject{
public:
  HttpHandler(){
  }
  void onHttpRequestCompleted(cocos2d::CCNode *sender, void *data){
    CCHttpResponse *response = (CCHttpResponse*)data;
    if (!response){
      return;
    }
    const char* tag = response->getHttpRequest()->getTag();
    CCLog("%s completed ", tag);

    vector<char> *charData = response->getResponseData();
    string res;
    res.assign(charData->begin(), charData->end());
    CCLog("completed %d, %s", res.size(), res.c_str());
     
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    pEngine->executeFunctionWithString(tag, res.c_str());
  }
};

HttpHandler httpHandler;

